/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package oids.frontEnd.components;

import java.awt.Color;
import java.awt.Graphics;
import oids.frontEnd.util.ComponentStepCalculation;
import oids.frontEnd.util.Point2D;

/**
 *
 * @author CJ
 */
public class Astroid extends Component{

    protected final int maxSpeed = 5;
    
    protected double radDirection;
    protected int speed;

    public Astroid(int x, int y, int size){
        super(x, y, size);
        this.size = size;
        this.radDirection = Math.random() * 2 * Math.PI;
        this.speed = this.maxSpeed;
    }

    public void draw(Graphics g){
        g.setColor(Color.LIGHT_GRAY);
        g.fillOval(this.x - this.size, this.y - this.size, this.size * 2, this.size * 2);
//        g.setColor(Color.white);
//        g.fillRect(this.x, this.y, 2, 2);
    }

    public void step(){
        stepThisAstroid();
    }

    protected void stepThisAstroid(){
        Point2D temp = ComponentStepCalculation.getStepInterval(radDirection, this.speed);
        this.setX(this.getX() + temp.getX());
        this.setY(this.getY() + temp.getY());
    }
}
